import { Entity, PrimaryGeneratedColumn, Column, Index,  } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

/**
 * 天赋石表
 * 存储玩家拥有的天赋石信息
 */
@Entity("talent_stone")
@ManualTimestamp()
@Index(["characterId", "name"]) // 为角色ID和天赋石名称建立索引
export class TalentStoneEntity {
  /**
   * 天赋石ID (主键)
   */
  @PrimaryGeneratedColumn({ type: "int", comment: "天赋石ID" })
  id!: number;

  /**
   * 角色ID
   */
  @Column({ type: "int", name: "character_id", comment: "角色ID" })
  characterId!: number;

  /**
   * 天赋石名称
   */
  @Column({ type: "varchar", length: 50, comment: "天赋石名称" })
  name!: string;

  /**
   * 天赋石等级
   */
  @Column({ type: "int", name: "level", default: 1, comment: "天赋石等级" })
  level!: number;

  /**
   * 元气值
   */
  @Column({ type: "int", name: "energy", default: 100, comment: "元气值" })
  energy!: number;

  /**
   * 天赋石类型
   */
  @Column({ type: "int", name: "type", comment: "天赋石类型" })
  type!: number;

  /**
   * 天赋石状态 (0:未激活, 1:已激活, 2:已装备到角色, 3:已装备到副将)
   */
  @Column({ type: "int", name: "state", default: 0, comment: "天赋石状态" })
  state!: number;

  /**
   * 装备的副将ID (如果装备到副将)
   */
  @Column({ type: "int", name: "deputy_id", nullable: true, comment: "装备的副将ID" })
  deputyId?: number;

  /**
   * 描述
   */
  @Column({ type: "varchar", name: "description", length: 200, nullable: true, comment: "描述" })
  description?: string;

  /**
   * 创建时间
   */
  @Column("datetime", { comment: "创建时间" })
  created_at!: Date;

  /**
   * 更新时间
   */
  @Column("datetime", { comment: "更新时间" })
  updated_at!: Date;
}

/**
 * 天赋石等级元气表
 * 存储每个等级对应的元气值和升级消耗
 */
@Entity("talent_stone_level")
@ManualTimestamp()
export class TalentStoneLevelEntity {
  /**
   * 等级 (主键)
   */
  @Column({ type: "int", primary: true, comment: "等级" })
  level!: number;

  /**
   * 该等级需要的元气值
   */
  @Column({ type: "int", name: "energy", comment: "该等级需要的元气值" })
  energy!: number;

  /**
   * 升级到该等级消耗的银两
   */
  @Column({ type: "int", name: "silver_cost", comment: "升级到该等级消耗的银两" })
  silverCost!: number;

  /**
   * 创建时间
   */
  @Column("datetime", { comment: "创建时间" })
  created_at!: Date;

  /**
   * 更新时间
   */
  @Column("datetime", { comment: "更新时间" })
  updated_at!: Date;
}

/**
 * 天赋石基础配置表
 * 存储天赋石的基础配置信息
 */
@Entity("talent_stone_base")
@ManualTimestamp()
export class TalentStoneBaseEntity {
  /**
   * 天赋石类型ID (主键)
   */
  @Column({ type: "int", name: "type_id", primary: true, comment: "天赋石类型ID" })
  typeId!: number;

  /**
   * 天赋石名称
   */
  @Column({ type: "varchar", length: 50, comment: "天赋石名称" })
  name!: string;

  /**
   * 天赋石描述
   */
  @Column({ type: "varchar", length: 200, comment: "天赋石描述" })
  description!: string;

  /**
   * 适用职业 (1:武士, 2:文人, 3:异人, 0:通用)
   */
  @Column({ type: "int", name: "role_type", comment: "适用职业" })
  roleType!: number;

  /**
   * 基础效果值
   */
  @Column({ type: "decimal", name: "base_effect", precision: 10, scale: 2, comment: "基础效果值" })
  baseEffect!: number;

  /**
   * 效果类型 (1:百分比, 2:固定值)
   */
  @Column({ type: "int", name: "effect_type", comment: "效果类型" })
  effectType!: number;

  /**
   * 创建时间
   */
  @Column("datetime", { comment: "创建时间" })
  created_at!: Date;

  /**
   * 更新时间
   */
  @Column("datetime", { comment: "更新时间" })
  updated_at!: Date;
}
